package com.example.teesystem.controller;

import com.example.teesystem.common.Permission.PermissionCheck;
import com.example.teesystem.common.utils.PermissionUtil;
import com.example.teesystem.common.utils.Response;
import com.example.teesystem.entity.vo.feature.FeatureTrainingRequestVo;
import com.example.teesystem.service.FeatureTrainingService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author pxr
 * @data 16/1/2023 下午3:26
 */

@RestController
@RequestMapping(value = "/tee/featureTraining" , produces = "application/json; charset=utf-8" )
@RequiredArgsConstructor
public class FeatureTrainingController {

    private final FeatureTrainingService featureTrainingService;

    @PostMapping(value = "/getIssue")
    public Response getIssue(@RequestBody FeatureTrainingRequestVo featureTrainingRequestVo){
        return featureTrainingService.getIssue(featureTrainingRequestVo);
    }

    @PostMapping(value = "/delete")
    @PermissionCheck(PermissionUtil.ISSUE_MANAGE)
    public Response deleteFeatureTraining(@RequestBody Map<String,Integer> map ){
        Integer id = map.get("id");
        return featureTrainingService.delete(id);
    }
    @PostMapping(value = "/teacherGetIssue")
    @PermissionCheck(PermissionUtil.ISSUE_MANAGE)
    public Response teacherGetIssue(FeatureTrainingRequestVo featureTrainingRequestVo){
        return featureTrainingService.teacherGetIssue(featureTrainingRequestVo);
    }

    @PostMapping(value = "/add")
    public Response add(@RequestBody Map<String,Integer> map){
        int id = map.get("issueId");
        return featureTrainingService.add(id);
    }
}
